package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Attention;
import cn.wolfcode.trip.base.mapper.AttentionMapper;
import cn.wolfcode.trip.base.service.IAttentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AttentionServiceImpl implements IAttentionService {
    @Autowired
    private AttentionMapper attentionMapper;

    @Override
    public void save(Attention attention) {
        if(attention.getId()==null){
            attention.setAttentionNum(1);
            attention.setFansNum(1);
            attention.setState(true);
            attentionMapper.insert(attention);
        }

    }

    @Override
    public Attention get(Long currentUserId, Long attentionUserId) {
        return attentionMapper.getById(currentUserId,attentionUserId);
    }

    @Override
    public void delete(Long id) {
        attentionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int fans(Long attentionUserId) {
        return attentionMapper.fansCount(attentionUserId);
    }

    @Override
    public int attentionNum(Long currentUserId) {
        return attentionMapper.attentionNum(currentUserId);
    }

    @Override
    public void deleteFocus(Long loginUserId, Long userId) {
        attentionMapper.deleteFocus(loginUserId,userId);
    }

    @Override
    public void insertFocus(Long loginUserId, Long userId) {
        attentionMapper.insertFocus(loginUserId,userId);
    }
}
